/*
** my_putaddr.c for my_putaddr in /home/leroy_v//my_printf
** 
** Made by vincent leroy
** Login   <leroy_v@epitech.net>
** 
** Started on  Wed Oct 17 21:56:56 2012 vincent leroy
** Last update Tue Feb 05 16:55:28 2013 vincent leroy
*/

#include <stdlib.h>
#include <unistd.h>

void	my_putnb(int nb)
{
    char c;
    if (nb < 10)
        c = nb + '0';
    else
        c = nb - 10 + 'a';

    write(1, &c, 1);
}

void	my_putaddr(void *addr)
{
    unsigned long	pow;
    unsigned long	nb;
    int		i;

    nb = (unsigned long)addr;
    pow = 1;
    i = 1;
    while (pow <= nb / 16)
    {
        pow *= 16;
        i++;
    }
    i = 0;
    while (pow >= 1)
    {
        my_putnb(nb / pow);
        nb %= pow;
        pow /= 16;
    }
}
